home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / ROM_Kernel_Manuals / Lib_examples / shadowborder.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-20  |  3.8 KB  |  121 lines

  1. ;/* shadowborder.c - Execute me to compile me with SAS C 5.10
  2. LC -b1 -cfistq -v -y -j73 shadowborder.c
  3. Blink FROM LIB:c.o,shadowborder.o TO shadowborder LIBRARY LIB:LC.lib,LIB:Amiga.lib
  4. quit
  5. **
  6. ** The following example draws a double border using two pens to create a
  7. ** shadow effect.  The border is drawn in two positions to show the
  8. ** flexibility in positioning borders, note that it could also be attached
  9. ** to a menu, gadget or requester.
  10. **
  11. ** shadowborder.c - program to show the use of an Intuition Border.
  12. */
  13. #define INTUI_V36_NAMES_ONLY
  14.  
  15. #include <exec/types.h>
  16. #include <intuition/intuition.h>
  17.  
  18. #include <clib/exec_protos.h>
  19. #include <clib/dos_protos.h>
  20. #include <clib/intuition_protos.h>
  21.  
  22. #include <stdio.h>
  23.  
  24. #ifdef LATTICE
  25. int CXBRK(void)    { return(0); }  /* Disable Lattice CTRL/C handling */
  26. int chkabort(void) { return(0); }  /* really */
  27. #endif
  28.  
  29. struct Library *IntuitionBase = NULL;
  30.  
  31. #define MYBORDER_LEFT   (0)
  32. #define MYBORDER_TOP    (0)
  33.  
  34. /* This is the border data. */
  35. WORD myBorderData[] =
  36.     {
  37.     0,0, 50,0, 50,30, 0,30, 0,0,
  38.     };
  39.  
  40.  
  41. /*
  42. ** main routine. Open required library and window and draw the images.
  43. ** This routine opens a very simple window with no IDCMP.  See the
  44. ** chapters on "Windows" and "Input and Output Methods" for more info.
  45. ** Free all resources when done.
  46. */
  47. VOID main(int argc, char **argv)
  48. {
  49. struct Screen   *screen;
  50. struct DrawInfo *drawinfo;
  51. struct Window   *win;
  52. struct Border    shineBorder;
  53. struct Border    shadowBorder;
  54.  
  55. ULONG mySHADOWPEN = 1;  /* set default values for pens */
  56. ULONG mySHINEPEN  = 2;  /* in case can't get info...   */
  57.  
  58. IntuitionBase = OpenLibrary("intuition.library",37);
  59. if (IntuitionBase)
  60.     {
  61.     if (screen = LockPubScreen(NULL))
  62.         {
  63.         if (drawinfo = GetScreenDrawInfo(screen))
  64.             {
  65.             /* Get a copy of the correct pens for the screen.
  66.             ** This is very important in case the user or the
  67.             ** application has the pens set in a unusual way.
  68.             */
  69.             mySHADOWPEN = drawinfo->dri_Pens[SHADOWPEN];
  70.             mySHINEPEN  = drawinfo->dri_Pens[SHINEPEN];
  71.  
  72.             FreeScreenDrawInfo(screen,drawinfo);
  73.             }
  74.         UnlockPubScreen(NULL,screen);
  75.         }
  76.  
  77.     /* open a simple window on the workbench screen for displaying
  78.     ** a border.  An application would probably never use such a
  79.     ** window, but it is useful for demonstrating graphics...
  80.     */
  81.     if (win = OpenWindowTags(NULL,
  82.                         WA_PubScreen,  screen,
  83.                         WA_RMBTrap,      TRUE,
  84.                         TAG_END))
  85.         {
  86.         /* set information specific to the shadow component of the border */
  87.         shadowBorder.LeftEdge   = MYBORDER_LEFT + 1;
  88.         shadowBorder.TopEdge    = MYBORDER_TOP + 1;
  89.         shadowBorder.FrontPen   = mySHADOWPEN;
  90.         shadowBorder.NextBorder = &shineBorder;
  91.  
  92.         /* set information specific to the shine component of the border */
  93.         shineBorder.LeftEdge    = MYBORDER_LEFT;
  94.         shineBorder.TopEdge     = MYBORDER_TOP;
  95.         shineBorder.FrontPen    = mySHINEPEN;
  96.         shineBorder.NextBorder  = NULL;
  97.  
  98.         /* the following attributes are the same for both borders. */
  99.         shadowBorder.BackPen    = shineBorder.BackPen   = 0;
  100.         shadowBorder.DrawMode   = shineBorder.DrawMode  = JAM1;
  101.         shadowBorder.Count      = shineBorder.Count     = 5;
  102.         shadowBorder.XY         = shineBorder.XY        = myBorderData;
  103.  
  104.         /* Draw the border at 10,10 */
  105.         DrawBorder(win->RPort,&shadowBorder,10,10);
  106.  
  107.         /* Draw the border again at 100,10 */
  108.         DrawBorder(win->RPort,&shadowBorder,100,10);
  109.  
  110.         /* Wait a bit, then quit.
  111.         ** In a real application, this would be an event loop, like the
  112.         ** one described in the Intuition Input and Output Methods chapter.
  113.         */
  114.         Delay(200);
  115.  
  116.         CloseWindow(win);
  117.         }
  118.     CloseLibrary(IntuitionBase);
  119.     }
  120. }
  121.